package com.trkj.dao;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.trkj.pojo.Loanlog;

public interface LoanlogDAO extends JpaRepository<Loanlog, Integer>,JpaSpecificationExecutor<Loanlog> {
	
	@Query(nativeQuery=true,value="SELECT loanlog.*,emp.emp_name from loanlog\r\n" + 
			" left JOIN emp on emp.emp_id=loanlog.emp_id\r\n" + 
			" where emp.emp_id=?1  ORDER BY loanlog_id DESC")
	public List<Object[]> findLoanlogInfo(Integer empId);
	
	@Query(nativeQuery=true,value="SELECT loanlog.*,emp.emp_name from loanlog left JOIN emp on emp.emp_id=loanlog.emp_id where emp.emp_id=?1 and loanlog_time BETWEEN ?2 and ?3 ORDER BY loanlog_id DESC")
	public List<Object[]> findLoanlogANDInfo(Integer empId,Date onetime,Date lasttime);
}
